<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <base href="#(basePath)"/>
  <title>银行卡收款人-添加</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="static/layui/css/layui.css" media="all">

	<script src="static/layui/layui.js"></script>
</head>
<body>
  <form class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 20px 0 0;">
  	  <input type="hidden" name="contacts.accountType" value="bankCard">
  	  <div class="layui-form-item">
	    <label class="layui-form-label">账户别名</label>
	    <div class="layui-input-block">
      		<input type="text" name="contacts.alias" maxlength="30" required  lay-verify="required" placeholder="账户别名" autocomplete="off" class="layui-input">
    		</div>
	  </div>
	  <div class="layui-form-item">
    		<label class="layui-form-label">商户名称</label>
    		<div class="layui-input-block">
      		<select name="contacts.merchCode" lay-filter="merchCode">
       			#for(item : merchList)
      				<option value="#(item.code)">#(item.code)-#(item.name)</option>
      			#end
      		</select>
    		</div>
  	 </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">开户名称</label>
	    <div class="layui-input-block">
      		<input type="text" name="contacts.accountName" maxlength="30" required  lay-verify="required" placeholder="账户开户名称" autocomplete="off" class="layui-input">
    		</div>
	  </div>
  	  <div class="layui-form-item">
	    <label class="layui-form-label">账户号</label>
	    <div class="layui-input-block">
	      <input type="tel" name="contacts.accountNo" maxlength="30" required  lay-verify="required" placeholder="账户号" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">公司(对公)/个人(对私)</label>
	    <div class="layui-input-block">
	      <input type="radio" name="contacts.isCompany" value="1" title="公司" checked>
	      <input type="radio" name="contacts.isCompany" value="0" title="个人">
	    </div>
      </div>
      <div class="layui-form-item">
    		<label class="layui-form-label">银行名称</label>
    		<div class="layui-input-block">
      		<select name="contacts.bankEnglishLetters" lay-filter="bankEnglishLetters">
				#for(item : topBankList)
				<option value="#(item.shortEnName)">#(item.shortEnName)-#(item.bankName)</option>
				#end
			</select>
    		</div>
  	 </div>


	 <div style="display: block" class="layui-form-item">
	    <label class="layui-form-label">开户支行名</label>
	    <div class="layui-input-block">
	      <input type="text" name="contacts.openingBankName"  maxlength="90" placeholder="开户行名" required  lay-verify="required" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div style="display: none" class="layui-form-item">
	    <label class="layui-form-label">开户行号(选填)</label>
	    <div class="layui-input-block">
	      <input type="tel" name="contacts.openingBankNo" maxlength="30" placeholder="开户行号" autocomplete="off" class="layui-input">
	    </div>
	  </div>

	  <div class="layui-form-item" id="area-picker">
		  <label class="layui-form-label">省份/城市</label>
		  <div class="layui-input-block">
			  <div class="layui-input-inline">
				  <select name="contacts.province" class="province-selector" data-value="" lay-filter="province">
					  <option value="">请选择省</option>
				  </select>
			  </div>
			  <div class="layui-input-inline">
				  <select name="contacts.city" class="city-selector" data-value="" lay-filter="city">
					  <option value="">请选择市</option>
				  </select>
			  </div>
		  </div>
	  </div>


	  <div style="display: none" class="layui-form-item">
	    <label class="layui-form-label">身份证号</label>
	    <div class="layui-input-block">
	      <input type="tel" maxlength="30" name="contacts.certsNo" placeholder="身份证号" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div style="display: none" class="layui-form-item">
	    <label class="layui-form-label">手机号</label>
	    <div class="layui-input-block">
	      <input type="tel" name="contacts.phoneNo" placeholder="手机号" maxlength="11" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">状态</label>
	    <div class="layui-input-block">
	      <input type="radio" name="contacts.isStop" value="0" title="启用" checked>
	      <input type="radio" name="contacts.isStop" value="1" title="禁用">
	    </div>
      </div>
	  <div class="layui-form-item layui-hide">
	    <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
	  </div>
  </form>

  <script>
  layui.config({
	base: '#(basePath)' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form', 'layarea'], function(){
    var $ = layui.$
    ,form = layui.form,layarea = layui.layarea;

    //监听提交
    form.on('submit(layuiadmin-app-form-submit)', function(data){
      var field = data.field; //获取提交的字段
      console.log(field);
      var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
      //提交 Ajax 成功后，关闭当前弹层并重载表格
      $.ajax({
    	  url: layui.setter.base+"admin/contacts/add",
    	  type:"post",
    	  data: field,
    	  success: function(res){
			  if(res.code !== 0){
				parent.layer.msg(res.msg, {icon: 2});
			  }else{
	    		  parent.layer.msg("添加成功", {icon: 1});
	    	      parent.layui.$("#LAY_app_body > div.layui-show iframe").get()[0].contentWindow.layui.table.reload('LAY-web-list'); //重载表格
	    	      parent.layer.close(index); //再执行关闭
			  }
    	  },
    	  error: function(xhr){parent.layer.msg("出错了" + xhr);}
      });
    });

      // 省市联动
      layarea.render({
          elem: '#area-picker',
          change: function (res) {
              console.log(res);
          }
      });

  })
  </script>

</body>
</html>
